package me.xingyannian.zhaopin.service;

import me.xingyannian.zhaopin.entity.ChangCi;
import me.xingyannian.zhaopin.entity.PreExaminee;
import me.xingyannian.zhaopin.repository.PreExamineeRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * PreExamineeService
 *
 * @author XING&WANG
 * @version 2025/05/05 13:08
 **/
@Service
public class PreExamineeService {
    private final PreExamineeRepository preExamineeRepository;

    public PreExamineeService(PreExamineeRepository preExamineeRepository) {
        this.preExamineeRepository = preExamineeRepository;
    }

    /**
     * 根据场次查询所有预报名考生信息
     * @param changCi 场次对象
     * @param pageNum 页码
     * @param pageSize 每页数量
     * @return Page<PreExaminee>
     */
    public Page<PreExaminee> findAllByChangCi(ChangCi changCi, int pageNum, int pageSize) {
        Pageable pageable = Pageable.ofSize(pageSize).withPage(pageNum);
        return this.preExamineeRepository.findAllByChangCi(changCi ,pageable);
    }
    @Transactional
    public void saveAll(List<PreExaminee> preExaminees) {
        this.preExamineeRepository.saveAll(preExaminees);
    }
    @Transactional
    public void deleteAllByChangCi(ChangCi changCi) {
        this.preExamineeRepository.deleteAllByChangCi(changCi);
    }

    public void schoolMatch(ChangCi changCi) {

    }
}
